<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="utf-8"/>
<title>Liên hệ</title>
<link rel="stylesheet" href="Css/cc.css"></link>
</head>
<body>
<div class="wrapper">
<?php include 'menu.php';?>
<div class="content">
    <?php
    $limit = 8;
        if (isset($_GET['page'])) 
            {
                $page = $con->real_escape_string($_GET['page']);
            } 
        else 
            {
                $page = 1;
            }
    if (isset($_POST['btncontact']))
    {
        $name =$con->real_escape_string($_POST["txtfullname"]);
        $email =$con->real_escape_string($_POST["txtemail"]);
        $phone =$con->real_escape_string($_POST["txtphone"]);
        $comment = $con->real_escape_string($_POST["txtcomment"]);
    if($row =$con->query("Insert into contact value('','{$name}', '{$email}', {$phone}, '{$comment}')"))
        {?>
    <div><br></br>Gửi thành công ấn vào đây <a href="index.php">đây</a> để trở về trang chủ.</div>
           <?php }
        }
    if (isset($_GET["asx"]))
    {
        $query = $con->query("Select count(*) from contact");
        $row3 = mysqli_fetch_array($query);
        $tongsp = $row3[0];
        $pages = ceil($tongsp / $limit);
        $offset = ($page - 1) * $limit;
        $result = $con->query("select * from contact LIMIT {$limit} offset {$offset}"); ?>
        <div><br></br><a href="javascript:history.go(-1)">Quay lại</a>
        <table border="1" width="95%" style="margin: 20px auto">
            <th>STT</th><th>Tên</th><th>Email</th><th>Điện thoại</th><th>Nội dung</th><th>Tùy chọn</th>
        <?php
        $i =1;
        while ($value = mysqli_fetch_array($result)){ ?>
            <tr>
                <td width="5%"><?php echo $i; ?></td><td width="8%"><?php echo $value['name'] ;?></td><td width="5%"><?php echo $value['email'] ;?></td><td width="10%"><?php echo $value['phone'] ?></td><td width="30%"><?php echo $value['comment'] ?></td><td width="10%"><a href="delete.php?xoa4=<?php echo $value['id'] ?>">Xóa</a></td>
            </tr>
        <?php $i++; } ?>
        </table>
        </div><a href="javascript:history.go(-1)">Quay lại</a><br></br>
        <?php }
?>
</div>
<div class="pages">
         <?php
         if (isset($_GET['asx']))
         {
            for($i=1;$i <= $pages; $i++)
            {
                echo "<a href=\"?asx=1&&page={$i}\">{$i}</a> "." ";
            }
          }
         ?>
    </div>
<div class="footer">
We are... Mr.Chuot Tru, Mr.Minh Ho
<hr  width="20%" style="margin-left:40%; margin-top:8px;"/>
<pre><br /><br />
Coppyright: Aitieducation
</pre>
</div>
</div>
</div>
</body>
</html>